package com.cookiesoft.order.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.cookiesoft.common.annotation.Log;
import com.cookiesoft.common.core.controller.BaseController;
import com.cookiesoft.common.core.domain.AjaxResult;
import com.cookiesoft.common.enums.BusinessType;
import com.cookiesoft.order.domain.ZhenPaymentdetails;
import com.cookiesoft.order.service.IZhenPaymentdetailsService;
import com.cookiesoft.common.utils.poi.ExcelUtil;
import com.cookiesoft.common.core.page.TableDataInfo;

/**
 * 支付详情，存储订单支付信息Controller
 *
 * @author anc
 * @date 2024-11-06
 */
@CrossOrigin
@RestController
@RequestMapping("/order/paymentdetails" )
public class ZhenPaymentdetailsController extends BaseController {
    @Autowired
    private IZhenPaymentdetailsService zhenPaymentdetailsService;

/**
 * 查询支付详情，存储订单支付信息列表
 */
@PreAuthorize("@ss.hasPermi('order:paymentdetails:list')" )
@GetMapping("/list" )
    public TableDataInfo list(ZhenPaymentdetails zhenPaymentdetails) {
        startPage();
        List<ZhenPaymentdetails> list = zhenPaymentdetailsService.selectZhenPaymentdetailsList(zhenPaymentdetails);
        return getDataTable(list);
    }

    /**
     * 导出支付详情，存储订单支付信息列表
     */
    @PreAuthorize("@ss.hasPermi('order:paymentdetails:export')" )
    @Log(title = "支付详情，存储订单支付信息" , businessType = BusinessType.EXPORT)
    @PostMapping("/export" )
    public void export(HttpServletResponse response, ZhenPaymentdetails zhenPaymentdetails) {
        List<ZhenPaymentdetails> list = zhenPaymentdetailsService.selectZhenPaymentdetailsList(zhenPaymentdetails);
        ExcelUtil<ZhenPaymentdetails> util = new ExcelUtil<ZhenPaymentdetails>(ZhenPaymentdetails. class);
        util.exportExcel(response, list, "支付详情，存储订单支付信息数据" );
    }

    /**
     * 获取支付详情，存储订单支付信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('order:paymentdetails:query')" )
    @GetMapping(value = "/{paymentId}" )
    public AjaxResult getInfo(@PathVariable("paymentId" ) Long paymentId) {
        return success(zhenPaymentdetailsService.selectZhenPaymentdetailsByPaymentId(paymentId));
    }

    /**
     * 新增支付详情，存储订单支付信息
     */
    @PreAuthorize("@ss.hasPermi('order:paymentdetails:add')" )
    @Log(title = "支付详情，存储订单支付信息" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZhenPaymentdetails zhenPaymentdetails) {
        return toAjax(zhenPaymentdetailsService.insertZhenPaymentdetails(zhenPaymentdetails));
    }

    /**
     * 修改支付详情，存储订单支付信息
     */
    @PreAuthorize("@ss.hasPermi('order:paymentdetails:edit')" )
    @Log(title = "支付详情，存储订单支付信息" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZhenPaymentdetails zhenPaymentdetails) {
        return toAjax(zhenPaymentdetailsService.updateZhenPaymentdetails(zhenPaymentdetails));
    }

    /**
     * 删除支付详情，存储订单支付信息
     */
    @PreAuthorize("@ss.hasPermi('order:paymentdetails:remove')" )
    @Log(title = "支付详情，存储订单支付信息" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{paymentIds}" )
    public AjaxResult remove(@PathVariable Long[] paymentIds) {
        return toAjax(zhenPaymentdetailsService.deleteZhenPaymentdetailsByPaymentIds(paymentIds));
    }
}
